package lesson2.com.biz;


import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;


public class CustomerTester {
    
    public static void main(String[] args){
        Customer c1 = new Customer("Kelby","Z",600.0D);
        Customer c2 = new Customer("John","Troyka",0.0D);
        Customer c3 = new Customer("Evan","Troyka",1000000.0D);
        Customer c4 = new Customer("Kelby","Z",50000.0D);
        
        List<Customer> custsList = new ArrayList<Customer>();
        custsList.add(c1);
        custsList.add(c2);
        custsList.add(c3);
        custsList.add(c4);
        //custsList.add(new FlyingSquirrel());
        System.out.println("Original list ");
        printList(custsList);
        
  //      Collections.sort(custsList);
  //      System.out.println("Sorted list");
  //      printList(custsList);
        
        System.out.println("Now sorting on credit limit.. NOT  the natural ordering");
        Collections.sort(custsList, new CustomerCreditLimitComparator() );
        printList(custsList);
        
        //Object obj = custsList.get(0);
        //Customer cz = (Customer)obj;
        Customer cz = custsList.get(0);
        cz.setLastName("Whatever");
        
        Iterator<Customer> it = custsList.iterator();
        while(it.hasNext()){
            cz = it.next();
        }
    }
    
    
    static void printList(List list){
        for(Object o: list){
            System.out.println("\t"+o.toString());
        }
    }
    
}